Arithmetic Operation
Q1.
Consider the following C program: #include < stdio.h > int main() { float sum = 0.0, j = 1.0, i = 2.0; while (i / j > 0.0625) { j = j + j; sum = sum + i/j; printf("%f \n", sum); } return 0; } The number of times variable sum will be printed When the above program is executed is _________ .Q2.
What is printed by the following ANSI C program?#include < stdio.h > int main(int argc, char *argv[]){ char a = 'P'; char b = 'x'; char c = (a & b) + '*'; char d = (a | b) - '-'; char e = (a ^ b) + '+'; printf("%c %c %c \n", c, d, e); return 0; } ASCII encoding for relevant characters is given belowQ3.
Consider the following C code segment: #include < stdio.h > main() { int i, j, x; scanf("%d", &x); i=1; j=1; while (i<10) { j =j*i; i= i+1; if(i==x) break; } }For the program fragment above, which of the following statements about the variables i and j must be true after execution of this program? [ !(exclamation) sign denotes factorial in the answer]Q4.
Consider the following C program: main() { float sum= 0.0, j=1.0,i=2.0; while(i/j>0.001){ j=j+1; sum=sum+i/j; printf("%f/n", sum); } }Q5.
What does the following program do when the input is unsigned 16 bit integer? #include < stdio.h > main(){ unsigned int num; int i; scanf("%u", #); for(i=0;i<16;i++){ printf("%d", (num < < i&1 < < 15)?1:0); } }Q6.
The attributes of three arithmetic operators in some programming language are given below. The value of the expression 2-5+1-7*3 in this language is_______ .Q7.
Consider the following C program. #include < stdio.h > int main ( ) { int m = 10; int n, n1; n = ++m; n1 = m++; n--; --n1; n-=n1; printf ("%d", n) ; return 0; } The output of the program is ______________.Q8.
Consider the following statements #define hypotenuse (a, b) sqrt (a*a+b*b);The macro call hypotenuse(a+2,b+3);Q10.
Consider the following program fragment i=6720; j=4; while (i%j)==0 { i=i/j; j=j+1; }On termination j will have the value